﻿using System;
using System.Collections.Generic;

using MSAcademic.v2.Infrastructure.AccessRights;
using MSAcademic.v2.Infrastructure.Gallery;
using MSAcademic.v2.Infrastructure.Login;
using MSAcademic.v2.Infrastructure.User;

namespace MSAcademic.v2.Web.Areas.Admin.Models.Gallery
{
    public partial class ShowAllGalleriesViewModel
    {
        public IEnumerable<IGallery> Galleries
        {
            get
            {
                if (_galleries == null)
                {
                    _galleries = new Lazy<IEnumerable<IGallery>>(() => _galleryQueries.GetAllGalleries(SignedInUser));
                }
                return _galleries.Value;
            }
        }
        private Lazy<IEnumerable<IGallery>> _galleries;
    }

    public partial class ShowAllGalleriesViewModel
    {
        public IUser SignedInUser
        {
            get
            {
                if (_signedInUser == null)
                {
                    _signedInUser = new Lazy<IUser>(() => _loginService.TryGetSignedInUser());
                }
                return _signedInUser.Value;
            }
        }
        private Lazy<IUser> _signedInUser;

        public bool CanView
        {
            get
            {
                if (_canView == null)
                {
                    _canView = new Lazy<bool>(() => this.SignedInUser != null);
                }
                return _canView.Value;
            }
        }
        private Lazy<bool> _canView;
    }

    public partial class ShowAllGalleriesViewModel
    {
        private readonly IGalleryQueries _galleryQueries;
        private readonly ILoginService _loginService;
        private readonly IAccessRightsService _accessRightsService;

        public ShowAllGalleriesViewModel(IGalleryQueries galleryQueries,
            ILoginService loginService,
            IAccessRightsService accessRightsService)
        {
            _galleryQueries = galleryQueries;
            _loginService = loginService;
            _accessRightsService = accessRightsService;
        }
    }
}